#include "mysig.h"

void (*signal2(int sig, void (*handler)(int sig))) (int sig);
void (*signal1(int sig, void (*handler)(int sig))) (int sig);


static void my_handler(int sig);

int main() {
    signal2(SIGUSR1, my_handler);
    FILE *sleep_pipe = popen("sleep 60; echo helloworld", "r");
    size_t nbytes = 1024;
    char *output = (char *) malloc(nbytes + 1);
    getdelim(&output, &nbytes, '\0', sleep_pipe);
    printf("%s\n", output);
    return EXIT_SUCCESS;
}

static void my_handler(int sig) {
    //signal(sig, my_handler); /* We have to do this, if we use 'signal' */
    printf("Recv signal %d\n", sig);
}
